﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Registeredusers.aspx.cs" Inherits="WeChat.Registeredusers" %>

<!DOCTYPE html>
<meta name="viewport" content="width=device-width,initial-scale=1" />	
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.3, maximum-scale=2.0, user-scalable=yes" />
    <title>用户注册</title>
    <link href="layui/css/layui.css" rel="stylesheet" />
       <script src="Script/jquery-1.8.3.min.js"></script>

       <script src="layer/layer.js"></script>
       <script src="http://www.jq22.com/jquery/jquery-3.3.1.js"></script>
</head>
<body style="width:100%;">
    <h1 style="text-align:center; margin-top:10px; ">用户注册</h1><br />
    <div style="margin:0 auto;  width:500px;">
	<form action="#" method="post">
	 <div class="layui-form-item">
	    <label class="layui-form-label">用户名</label>
	<div class="layui-input-inline">
	    <input type="text" id="txtname"  name="txtname" style="width:200px;" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
	</div>
	<div class="layui-form-mid layui-word-aux"></div>
	</div>

	<%--<div class="layui-form-item">
	    <label class="layui-form-label">卡号</label>
	<div class="layui-input-inline">
	    <input type="text" id="username"  name="username" style="width:200px;" required lay-verify="required" placeholder="请输入卡号" autocomplete="off" class="layui-input">
	</div>
	    <div  class="layui-form-mid layui-word-aux"></div>
	</div>--%>

	<div class="layui-form-item">
	    <label class="layui-form-label">密码</label>
	<div class="layui-input-inline">
	    <input type="password"id="password1"   name="password1" style="width:200px;" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
	</div>
	    <div class="layui-form-mid layui-word-aux"></div>
	</div>

	<div class="layui-form-item">
	    <label class="layui-form-label">确认密码</label>
	<div class="layui-input-inline">
	    <input type="password" id="password2"  name="password2" style="width:200px;" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
	</div>
	    <div class="layui-form-mid layui-word-aux"></div>
	</div>
	
	<div class="layui-form-item">
	    <label class="layui-form-label">手机号码</label>
	<div class="layui-input-inline">
	    <input type="text" id="phone"  name="phone" style="width:200px;" required lay-verify="required" placeholder="请输入手机号码" autocomplete="off" class="layui-input">
	</div>
	    <div class="layui-form-mid layui-word-aux"></div>
	</div>

	<div class="layui-form-item">
	    <label class="layui-form-label">性别</label>
	<div class="layui-input-inline" style="padding-top:10px;">
	    <input type="radio" name="sex" style="width:50px;" value="男"/>男
	    <input type="radio" name="sex" style="width:50px;" value="女"/>女
	</div>
	    <div class="layui-form-mid layui-word-aux"></div>
	</div>

	<div class="layui-input-block">
	     <button id="SubTi"  name="SubTi"   class="layui-btn" >立即注册</button>
	     <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
	</form>
    </div>
    <script type="text/javascript">
	$(function () {
	    $("#SubTi").click(function () {

		var txtname = $("#txtname").val();
		if (txtname == null || txtname == "") {
		    layer.msg("请输入用户名！", { icon: 5 });
		    return false;
		}

		var username = $("#username").val();
		var rs = /^#?([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$/;
		//if (username == null || username == "") {
		//    layer.msg("请输入卡号！", { icon: 5 });
		//    return false;
		//}
		//if (username!="") {
		//    if (!rs.test(username)) {
		//	layer.msg("卡号格式不正确！", { icon: 5 });
		//	return false;
		//    }
		//}




		var password1 = $("#password1").val();
		if (password1 == null || password1 == "") {
		    layer.msg("请输入密码！", { icon: 5 });
		    return false;
		}
		var password2 = $("#password2").val();
		if (password2 == null || password2 == "") {
		    layer.msg("请输入密码！", { icon: 5 });
		    return false;
		} else if (password1 != password2) {
		    layer.msg("两次密码输入不一致！", { icon: 5 });
		    return false;
		}

		var phone = $("#phone").val();
		if (phone == null || phone=="") {
		    layer.msg("请输入手机号码！", { icon: 5 });
		    return false;
		}
		var resPhone = /^1[34578]\d{9}$/;
		if (!resPhone.test(phone)) {
		    layer.msg("手机号码格式错误！", { icon: 5 });
		    return false;
		}

		var sex = $("input:radio:checked").val();
		if (sex == "" || sex == null) {
		    layer.msg("请选择性别！", { icon: 5 });
		    return false;
		}
		$.ajax({
		    url: "Actionregistration.ashx",
		    data: { txtname: txtname, phone: phone, username: username, password1: password1, sex: sex, pageType: "Register" },
		    success: function (data) {
			if (data == '0') {
			    layer.msg('注册成功，是否跳登录页面？', {
				time: 0 //不自动关闭
				, btn: ['确定', '取消']
				, yes: function (index) {
				    layer.close(index);
				    window.location.href = "Binding.aspx";
				}
			    });
			} else if (data == "1") {
			    layer.msg("注册失败！", { icon: 5 });
			    return false;
			} else if (data == "2") {
			    layer.msg("此卡号已被已注册！", { icon: 5 });
			    return false;
			} else if (data == "3") {
			    layer.msg("此用户已被注册！")
			} else {
			    layer.msg("网络繁忙！", { icon: 5 });
			    return false;
			}
		    }
		});
		return false;
	    });
	});
    </script>
</body>
</html>


